<?php

/**
 * Application filter form base class.
 *
 * @package    KC-INDICATEURS
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseApplicationFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'categorie_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Categorie'), 'add_empty' => true)),
      'projet_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Projet'), 'add_empty' => true)),
      'nom_court'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'nom'             => new sfWidgetFormFilterInput(),
      'recette_version' => new sfWidgetFormFilterInput(),
      'recette_date'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'prod_version'    => new sfWidgetFormFilterInput(),
      'prod_date'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'commentaire'     => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'categorie_id'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Categorie'), 'column' => 'id')),
      'projet_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Projet'), 'column' => 'id')),
      'nom_court'       => new sfValidatorPass(array('required' => false)),
      'nom'             => new sfValidatorPass(array('required' => false)),
      'recette_version' => new sfValidatorPass(array('required' => false)),
      'recette_date'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'prod_version'    => new sfValidatorPass(array('required' => false)),
      'prod_date'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'commentaire'     => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('application_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Application';
  }

  public function getFields()
  {
    return array(
      'id'              => 'Number',
      'categorie_id'    => 'ForeignKey',
      'projet_id'       => 'ForeignKey',
      'nom_court'       => 'Text',
      'nom'             => 'Text',
      'recette_version' => 'Text',
      'recette_date'    => 'Date',
      'prod_version'    => 'Text',
      'prod_date'       => 'Date',
      'commentaire'     => 'Text',
    );
  }
}
